Socket
Socket
Sign inDemoInstall

shq

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    shq

Quote a string for safe use as a shell argument. Strips null characters.


Version published
Weekly downloads
15K
decreased by-1%
Maintainers
1
Install size
6.07 kB
Created
Weekly downloads
 

Readme

Source

shq

Quote a string for safe use as a shell argument. Strips null characters.

API

This module ESM-exports one function that holds some methods:

shq(x)

  • Stringify x,
  • remove all U+0000 null characters, because all too often, some C program in the pipeline will screw it up even if properly quoted,
  • and in case it contains special characters, quote it.

shq.cfg(opt)

Return a customized quoting function. opt is an optional options object that supports these keys:

  • empty: How to represent the empty string. Default: A pair of single quotes.
  • gratuitous: What string to put on both sides of a non-empty input that doesn't need to be quoted.

shq.always

A quoting function that adds gratuitous single quotes (cf. .cfg).

Usage

see test/usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

Keywords

FAQs

Last updated on 07 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc